package com.maplefire.service.impl;

import com.maplefire.annotation.MessageHandlerType;

import java.lang.annotation.Annotation;

public class MessageHandlerTypeImpl implements MessageHandlerType {

    private String operateType;

    private String source;

    public MessageHandlerTypeImpl(String operateType, String source) {
        this.operateType = operateType;
        this.source = source;
    }

    @Override
    public String operateType() {
        return operateType;
    }

    @Override
    public String source() {
        return source;
    }

    @Override
    public Class<? extends Annotation> annotationType() {
        return MessageHandlerType.class;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof MessageHandlerType)) {
            return false;
        }
        MessageHandlerType other = (MessageHandlerType) o;
        return source.equals(other.source()) && operateType.equals(other.operateType());
    }

    @Override
    public int hashCode() {
        int hashCode = 0;
        hashCode += (127 * "source".hashCode()) ^ source.hashCode();
        hashCode += (127 * "operateType".hashCode()) ^ operateType.hashCode();
        return hashCode;
    }
}
